﻿<UserControl x:Class="TheVerge.Phone.Controls.NewsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:con="clr-namespace:TheVerge.Phone.Controls"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">
    <UserControl.Resources>

        <Style TargetType="Button" BasedOn="{StaticResource clearButtonStyle}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Padding" Value="0" />
        </Style>

        <Style TargetType="con:InfiniteScroller">
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <ContentControl ContentTemplate="{StaticResource articleItemWithImageTemplate}" Content="{Binding}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"  />
                            <Button Click="Article_Click" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="newsGrid" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <con:HeaderControl />

        <controls:Pivot x:Name="thePiv" SelectionChanged="thePiv_SelectionChanged" Grid.Row="1"
                        DataContext="{Binding News}"
                        HeaderTemplate="{StaticResource headerTemplate}"
                        TitleTemplate="{StaticResource PivotTitleTemplate}"
                        SelectedItem="{Binding SelectedEntries, Mode=TwoWay}"
                        ItemsSource="{Binding Entries}">
            <controls:Pivot.ItemTemplate>
                <DataTemplate>
                    <con:InfiniteScroller />    
                </DataTemplate>
            </controls:Pivot.ItemTemplate>
        </controls:Pivot>

        <con:ArticleEntryControl x:Name="aec1" Grid.RowSpan="2" />
    </Grid>
</UserControl>
